
import axios from "axios";

// 在此获取令牌
const authorization = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEwODUsInNpZ24iOiJhZGU3OGJkNGEwYjM3Nzc1MGM4ZGEzMDhhZWI3OTA4MiIsImV4cCI6MTczNTY5ODUyNCwibmJmIjoxNzA5Nzc4NTI0LCJpYXQiOjE3MDk3Nzg1MjR9.PbPe5nizGtxwvDFE27MG6oQAJSPycTi6gZRq7BhzM9M";
const api = axios.create({
    baseURL: "https://www.opchatai.site/api/",
    timeout: 10000,
    headers: {
        Authorization: authorization
    }
});

export const fetchData = async (url: string) => {
    try {
        const response = await api.get(url);
        return response.data.data;
    } catch (error) {
        console.error(`Error fetching data from ${url}:`, error);
        throw error;
    }
};